import request from '../utils/request'
// import store from '../store'
// 请求等录
export const login = (data) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    data
  })
}

// 请求发送验证码
export const sendYzm = mobile => {
  return request({
    method: 'get',
    url: `/v1_0/sms/codes/${mobile}`
  })
}

// 获取用户信息
export const getUserInfo = () => {
  return request({
    method: 'get',
    url: '/v1_0/user'
    // headers: {
    //   Authorization: `Bearer ${store.state.user.token}`
    // }
  })
}

// 获取首页tab栏频道列表
export const getChannelList = () => {
  return request({
    method: 'get',
    url: '/v1_0/user/channels'
  })
}

// 用户关注
export const userFollow = data => {
  return request({
    method: 'post',
    url: '/v1_0/user/followings',
    data
  })
}

// 用户取消关注
export const userNotFollow = target => {
  return request({
    method: 'delete',
    url: `/v1_0/user/followings/${target}`
  })
}

// 文章收藏
export const collectArticle = data => {
  return request({
    method: 'post',
    url: '/v1_0/article/collections',
    data
  })
}

// 取消收藏
export const deleteCollect = target => {
  return request({
    method: 'delete',
    url: `/v1_0/article/collections/${target}`
  })
}

// 文章点赞
export const likeArticle = data => {
  return request({
    method: 'post',
    url: '/v1_0/article/likings',
    data
  })
}

// 取消点赞
export const notLikeArticle = target => {
  return request({
    method: 'delete',
    url: `/v1_0/article/likings/${target}`
  })
}

// 获取当前个人资料
export const getUserProfile = () => {
  return request({
    method: 'get',
    url: '/v1_0/user/profile'
  })
}
// 更新当前个人资料
export const updateUserProfile = data => {
  return request({
    method: 'patch',
    url: '/v1_0/user/profile',
    data
  })
}
